package com.sjd.controller;

import com.sjd.pojo.User;
import com.sjd.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserServiceImpl userService;
    @RequestMapping("/getUserList")
    public List<User> getUserList(){
        List<User> userList = userService.getUserList();
        return userList;
    }

    @RequestMapping("/getUserById/{id}")
    public User getUserByid(@PathVariable("id") int id){
        return  userService.getUserByid(id);
    }

    @RequestMapping("/addUser")
    public String addUser(){
        userService.addUser(new User(10,"抬会强","123"));
        return "ok";
    }

    @RequestMapping("/modifyUser")
    public String modifyUser(){
        userService.modifyUser(new User(10,"抬会强","222"));
        return "ok";
    }
    @RequestMapping("/deleteById")
    public String deleteUserById(){
        userService.deleteUserById(10);
        return "ok";
    }

}
